﻿
namespace Web.Control.Member.User
{
	using System;
	using System.Data;
	using System.Drawing;
	using System.Web;
	using System.Web.Security;
	using System.Web.UI.WebControls;
	using System.Web.UI.HtmlControls;
	using System.Text.RegularExpressions;
    using Lx.Web.Common.UI;
    using Lx.Web.Common.ControlsUI;
	using System.Collections;
    using System.Collections.Generic;

    using Model.WWW_User.User;
    using BLF.WWW_User.Users;

    public class Registercomplete : BaseControl
	{
		
		protected UserModel bum=new UserModel();
        protected Literal CodeImage;
        /// <summary>
        /// 判断是否为注册时候进来
        /// 默认是注册成功，当为1的时候是还没通过邮件验证；
        /// </summary>
        protected string step = "2";
        protected String memberno = "";

		protected override void OnLoad(EventArgs e)
		{
			if(!Page.IsPostBack)
			{
                
                if (Request["step"] != null)
                {
                    if (Request["step"].ToString() == "2")
                    {
                        if (string.IsNullOrEmpty(Request.Form["Flag"]) || Request.Form["Flag"] != "1")
                        {
                            Response.End(); return;
                        }
                        if (Request["uid"] != null)
                        {
                            memberno = Request["uid"].ToString();
                            if (!String.IsNullOrEmpty(memberno)&&memberno!="")
                            {
                                bum = User.GetDetailUserInfo(memberno);
                            }
                        }
                        else
                        {
                            Response.End(); return;
                        }
                        if (Session["ref"] != null && Session["ref"].ToString().ToUpper() == "BEYONET")
                        {
                            if (CodeImage != null)
                            {
                                CodeImage.Visible = true;
                                CodeImage.Text = "<img width=1 height=1 border=0 src='http://www.beyonet.com/cgi-bin/tracklead.pl?camp_id=115&order_id=" + bum.MemberNo.ToString() + "'>";
                            }
                            Session["ref"] = null;
                        }

                    }
                    else if (Request["step"].ToString() == "1")
                    {
                        memberno = HttpContext.Current.User.Identity.Name;
                        if (memberno == "")
                        {
                            Page.Response.Redirect(LoginHost + "/User/login.htm?ReturnUrl=" + Page.Request.Url.AbsoluteUri);
                            return;
                        }
                        bum = User.GetDetailUserInfo(memberno);
                        step = "1";
                    }
                    else
                    {
                        Response.End();
                    }
                }
                else
                { 
                    Response.End();
                }
			}
			base.OnLoad (e);
		}
        /// <summary>
        /// 得到对应Email的登陆网站
        /// </summary>
        /// <param name="selectValue">Email@后面的字</param>
        /// <returns>带连接的图片</returns>
        public string GetEmailImg(string selectValue)
        {
            DataSet ds = new DataSet();
            ds.ReadXml(Server.MapPath(String.Format("/Control/{0}", "EmailUrl.xml")));
            DataTable dt = ds.Tables[0];
            return GetTextFromDT(dt, selectValue);
        }
        private string GetTextFromDT(DataTable dt, string value)
        {
            foreach (DataRow dr in dt.Rows)
            {
                if (dr[0].ToString().ToLower() == value.ToLower())
                {
                    return dr[1].ToString();
                }
            }
            return "";
        }
	}
}

